<%@ include file="/common/taglibs.jsp"%>
<%@ page pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<!-- jquery -->
		<script src="${jquery}/jquery.js"></script>
		<script src="${jquery}/jquery.form.js"></script>
		<!-- ztree -->
		<link rel="stylesheet" href="${ztree}/ztree/zTreeStyle.css"
			type="text/css">
		<script type="text/javascript" src="${ztree}/jquery.ztree.core.js"></script>
		<script type="text/javascript" src="${ztree}/jquery.ztree.excheck.js"></script>
		<!-- colorbox -->
		<script type="text/javascript"
			src="${colorbox}/jquery.colorbox-min.js"></script>
		<link rel="stylesheet" type="text/css" href="${colorbox}/colorbox.css">
		<!-- easyui -->
		<script type="text/javascript" src="${easyui}/jquery.easyui.min.js"></script>
		<link rel="stylesheet" type="text/css"
			href="${easyui}/themes/default/easyui.css">
		<!-- app -->
		<link rel="stylesheet" type="text/css" href="${app}/hnjz.css">
	</HEAD>

	<body>
		
			<form id="queryForm" method="post" action="saveRoleFunc.json">
				<input type="hidden" name="roleFuncIds" id="roleFuncIds">
				<div id="search" class="divContainer">
					<input class="i-text" type="text" id="role" name="role" value="${role}" />
					<span class="btn btn-ok"> <input type="submit" value="保存">
					</span>
					<a href="#" id="ref">刷新权限内存数据</a>
				</div>
				<div class="divContainer">
					<div class="easyui-panel" title="手机菜单信息" style="width:500px;">
					   <ul id="treeDemo" class="ztree"></ul>
					</div>
				</div>
			</form>
		
		<p>
	</body>
</HTML>
<SCRIPT LANGUAGE="JavaScript">
var setting = {
	check: {
		enable: true,
		chkStyle: "checkbox",
		chkboxType: {'Y': 'ps', 'N': 'ps'}
	},
	data: {
		simpleData: {
			enable: true,
			idKey: "id",
			pIdKey: "pid"
		}
	}
};
var treeObj = null;
$(document).ready(function(){
    var mmm = ${re};
	treeObj = $.fn.zTree.init($("#treeDemo"), setting,mmm);
	treeObj.expandAll(true);
    $("#ref").click(function(){
	  $.ajax({
			  url: "refRoleFunc.json",
			  success:function(data){
				  $.messager.alert('刷新结果:',data.msg);
			  }
			});
	});
    $('#role').combobox({
		url:'queryAllRole.json',
		valueField:'id',
		textField:'name',
		onSelect:function(){
		  var val = $('#role').combobox('getValue');
		  location.href="roleFunc.htm?role="+val;
		}
	});
});
$('#queryForm').submit(function(){
       var nodes=treeObj.getCheckedNodes(true);
		var ids='';
		$.each(nodes,function(index,ele){
				ids+=ele.id+',';
		});
	  $('#roleFuncIds').val(ids);
      $("#queryForm").ajaxSubmit({
     	  success: function(data){
	         $.messager.alert('保存结果:',data.msg);
	      }
	 });
     return false;  
});  
</SCRIPT>